package com.sunlong.jiangwei.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import tk.mybatis.mapper.annotation.KeySql;

import javax.persistence.Id;
import javax.persistence.Transient;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * <p>
 *
 * </p>
 *
 * @author 孙龙
 * @since 2021-02-19
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class JwUser implements Serializable {


    @Id
    @KeySql(useGeneratedKeys = true)
    private Long userId;

    /**
     * 用户名
     */
    private String username;

    /**
     * 密码，加密存储
     */
    @JsonIgnore
    private String password;

    /**
     * 注册手机号
     */
    private String phone;

    /**
     * 创建时间
     */
    private Date created;

    /**
     * 用户类型：0为系统管理员用户，1为商家用户，2为客户用户
     */
    private Integer type;

    private Long storeId;

    @Transient
    private String createdStr;

    @Transient
    private String roleNames;

    @Transient
    private Long roleId;

    public String getCreatedStr() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
        String format = sdf.format(created);
        return format;
    }


}
